package com.bua.control;

import android.content.Context;
import android.widget.Button;
import android.util.AttributeSet;
import android.view.View;

public class SingleCheckButton extends Button {

	private Context mContext = null;
	private SingleAlert singleAlert = null;
	public String[] items;
	public int checked;
	private String checkedString;
	public SingleCheckButton(Context context) {
		super(context);
		mContext = context;
		this.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				ShowCheckList();
			}
		});
		// TODO Auto-generated constructor stub

	}

	public SingleCheckButton(Context context, AttributeSet attrs) {
		super(context, attrs);

		mContext = context;
		this.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				ShowCheckList();
			}
		});
	}

	public SingleCheckButton(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);

		mContext = context;
		this.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				ShowCheckList();
			}
		});
	}

	public void SetItems(String[] itemArray) {
		items = itemArray;
		checked = 0;
	}

	public String GetTitle() {
		return this.getText().toString();
	}

	public void UpdateTitle() {
		
		checkedString=items[checked];
		this.setText(checkedString);
	}

	public void SetItemChecked(int index) {
		checked = index;
	}

	public void ShowCheckList() {
		singleAlert = new SingleAlert(mContext, this);
		singleAlert.Show();
	}

}
